import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:learning/components/MyText.dart';
import 'package:learning/components/SubjectCard.dart';
import 'package:learning/generated/l10n.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  @override
  State<IndexPage> createState() => _IndexPage();
}

class _IndexPage extends State<IndexPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void didUpdateWidget(IndexPage oldWidget) {
    super.didUpdateWidget(oldWidget);
  }

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
    });
  }

  @override
  Widget build(BuildContext context) {
    List<Tab> tabs = <Tab>[
      Tab(child: MyText(S.of(context).kemuone)),
      Tab(child: MyText(S.of(context).kemutwo)),
    ];

    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: BrnAppBar(
         //   backgroundColor: Colors.blue.shade100,
              shadowColor: Colors.blue,

              title: MyText(S.of(context).home),
              automaticallyImplyLeading: false,
              bottom: new TabBar(
                  unselectedLabelColor: Colors.black38, //未选中控件颜色
                  indicatorColor: Colors.blue, //指示器的颜色
                  labelColor: Colors.blue,
                  tabs: tabs)),
          body: TabBarView(children: [
            SubjectCard(
              title: S.of(context).kemuone,
              subject: 1,
            ),
            SubjectCard(
              title: S.of(context).kemusix,
              subject: 4,
            ),
          ]),
        ));
  }

  List<Tab> getTabs(BuildContext context) {
    List<Tab> tabs = <Tab>[
      Tab(icon: Icon(Icons.local_florist), child: MyText(S.of(context).home)),
      const Tab(icon: Icon(Icons.change_history)),
    ];
    return tabs;
  }
}
